package Test_0813;

import org.w3c.dom.ls.LSOutput;

import java.util.Arrays;

/**
 * Created with Intellij IDEA
 * Description:
 * User: 星辰
 * Dare: 2024-08-13
 */
public class Test {
    public static void main(String[] args)
            //处理异常
            throws CloneNotSupportedException{
        Animal animal=new Animal(2,"动物");
        animal.age=3;
        Animal animal2=(Animal) animal.clone();
        System.out.println(animal2.toString());
        //a
        System.out.println(animal2.a);//23
        animal2.a=4;
        System.out.println(animal2.a);//4
        System.out.println(animal.a);//23
        //b
        System.out.println(animal.b);//Test_0813.IB@4f3f5b24
        System.out.println(animal.b);//Test_0813.IB@4f3f5b24
        System.out.println(animal2.b.ib);//1
        animal2.b.ib=4;
        System.out.println(animal.b);//Test_0813.IB@4f3f5b24
        System.out.println(animal.b);//Test_0813.IB@4f3f5b24
        System.out.println(animal2.b.ib);//4
        System.out.println(animal.b.ib);//1
    }
    public static void main3(String[] args) {
        Student stu1=new Student(16,"张三");
        Student stu2=new Student(20,"李四");
        //两个之间
        //年龄
        AgeComparator age=new AgeComparator();
        System.out.println(age.compare(stu1,stu2));
        //姓名
        NameComparator name=new NameComparator();
        System.out.println(name.compare(stu1,stu2));
        //数组
        Student[] stus=new Student[3];
        stus[0]=new Student(16,"b");
        stus[1]=new Student(20,"c");
        stus[2]=new Student(28,"a");
        //年龄排序
        Arrays.sort(stus,age);
        System.out.println(Arrays.toString(stus));
        //姓名排序
        Arrays.sort(stus,name);
        System.out.println(Arrays.toString(stus));

    }
    public static void main2(String[] args) {
        Student[] stus=new Student[3];
        stus[0]=new Student(16,"b");
        stus[1]=new Student(20,"c");
        stus[2]=new Student(14,"a");
        //排序
        Arrays.sort(stus);
        //打印排序后的数组内容
        System.out.println(Arrays.toString(stus));
    }
    public static void main1(String[] args) {
        Student stu1=new Student(16,"张三");
        Student stu2=new Student(20,"李四");
        //compareTo的调用
        //stu1相当于compareTo中的this，stu2相当于o
       // System.out.println(stu1.compareTo(stu2));
    }
}
